package com.sw.rpc;

import com.sw.rpc.annotation.SpringBootApplication;
import com.sw.rpc.bootstrap.SpringApplication;
import com.sw.rpc.server.ProviderServer;
import com.sw.rpc.service.zk.ServiceInstanceService;
import com.sw.rpc.service.zk.ZkNodeData;

import java.io.IOException;

/**
 * @author sw
 * @project zdy-rpc
 * @description
 * @date 2020/5/15 13:37
 */
@SpringBootApplication
public class ServerBootStrap {
    public static void main(String[] args) throws InterruptedException, IOException, IllegalAccessException, InstantiationException {
        SpringApplication.run(ServerBootStrap.class, args);
        int port=Integer.valueOf(args[0]);
        String ip="127.0.0.1";
        ProviderServer.startServer(ip,port);

        //注册服务端口到
        try {
            //启动zk
            ServiceInstanceService.createCuratorZookeeperClient();
            //注册服务
            ZkNodeData zkNodeData=new ZkNodeData(ip,port);
            ServiceInstanceService.createPath("localhost:"+port,zkNodeData);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }






}
